package Euler48;

import java.math.BigInteger;

public class SelfPowers {
	public static void main(String[] args) {
		long max = 1000;
		long sum = 0;
		BigInteger modSum = BigInteger.ZERO;
		BigInteger mod = new BigInteger(String.valueOf(((long)Math.pow(10, 10))));
		String str = "";
		
		for(int i = 1; i <= max; i++)
		{
			//long pow = (long) Math.pow(i, i);
			//sum += pow;
			
			BigInteger val = new BigInteger(String.valueOf(i));
			BigInteger pow = val.pow(i);
			modSum = modSum.add(pow.mod(mod));
			
			/*if(i==max){
				str += (i + "^" + i);
			}
			else
			{
				str += (i + "^" + i + " + ");
			}*/
		}
		
		//System.out.println(str + " = " + sum);
		System.out.println(modSum.mod(mod));
	}
}
